package com.jt.tenant.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.GetInformation;
import com.jt.tenant.conn.GetQueryFence;
import com.jt.tenant.widget.Tools;

import java.util.List;

/**
 * Created by Administrator on 2016/2/14.
 */
public class InformationAdapter extends BaseAdapter {

    private LayoutInflater layoutInflater;

    private Context context;

    private View titleView;

    private List<GetInformation.InfomationItem> list;

    public InformationAdapter(Context context,List<GetInformation.InfomationItem> list){

        this.context = context;

        this.layoutInflater = ((Activity)context).getLayoutInflater();

        this.list = list;

    }

    @Override
    public int getCount() {

        return list.size();

    }

    @Override
    public Object getItem(int position) {

        return null;

    }

    @Override
    public long getItemId(int position) {

        return 0;

    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder;

        if (convertView == null){

            convertView = JTApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_home_rtinfo, null));

            viewHolder = new ViewHolder();

            viewHolder.title = (TextView) convertView.findViewById(R.id.tv_home_rtinfo_title);

            viewHolder.message = (TextView)convertView.findViewById(R.id.tv_home_rtinfo_message);

            convertView.setTag(viewHolder);

        }else{

            viewHolder = (ViewHolder) convertView.getTag();

        }

        if (position < list.size() - 1){

            convertView.setBackgroundColor(Color.WHITE);

        }else{

            convertView.setBackgroundResource(R.drawable.bian_bottom_c4c4c4_ffffff);

        }

        viewHolder.title.setText(list.get(position).title);

        viewHolder.message.setText(list.get(position).message);

        return convertView;

    }

    @Override
    public void notifyDataSetChanged() {

        super.notifyDataSetChanged();

    }


    private class ViewHolder{

        private TextView title;

        private TextView message;

    }

}
